package com.atguigu.oshiapp.oshiapp.controller;

import com.atguigu.oshiapp.oshiapp.common.R;
import com.atguigu.oshiapp.oshiapp.service.CpuLoadMetricsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @Author: Mouoal
 * @CreateTime: 2025-01-06  23:10
 * @Version: 1.0
 */
@CrossOrigin
@RestController
@RequestMapping("/metrices")
public class CpuLoadRestController {

    @Autowired
    CpuLoadMetricsService cpuLoadMetricsService;


    /**
     * {
     *     code:200,
     *     msg:"ok",
     *     data:null
     *
     * }
     */
    @ResponseBody
    @GetMapping("/cpuload")
    public R getCpuLocad(){

        double[] cpuLoad = cpuLoadMetricsService.getCpuLoad();

        return R.ok(cpuLoad);
    }
}
